{extends file="../home.html"}
{block name="title"}{$head_title}{/block}
{block name="css"}
<!-- <link rel="stylesheet" style="text/css" href="__PUBLIC__/Css/front/user_glb.css?version={$version}"> -->

<style type="text/css">
    body{
    	padding-top:2.2rem;
    }
</style>
{/block}
{block name="content"}
{include file="../common_header.html"}
<form>
<ul class="visit_from">
    <li class="clearfix">
        <label for="yin" class="fl">真实姓名</label>
        <input type="text" id="yin" name="real_name" value="" placeholder="请输入真实姓名">
    </li>
    <li class="clearfix">
        <label for="date" class="fl">手机号</label>
        <input type="number" id="date" name="phone" value="" placeholder="请输入手机号">
    </li>
    <li class="clearfix">
        <label for="name" class="fl">公司名称</label>
        <input type="text" id="name" name="company_name" value="" placeholder="请输入公司名称">
    </li>
    <li class="clearfix">
        <label for="name_ren" class="fl">职位</label>
        <input type="text" id="name_ren" name="position" value="" placeholder="请输入职位">
        <input type="hidden" name="activity_id" value="{$activity_id}">
        <input type="hidden" name="opt" value="add">
    </li>
</ul>
 </form>
<span class="submit_btn">提交</span>
{/block}
{block name="js"}
<script>
    var activity_id={$activity_id};
    
</script>
{literal}

<!-- <script type="text/javascript" src="__PUBLIC__/Js/front/iscroll.js"></script> -->
        <script type="text/javascript">
            $(function()
            {
                $(".submit_btn").on("click",function()
                {
                   console.log('aa');
                    if($("#yin").val()=='')
                    {
                        layer.open({
                            content: '请输入真实姓名',
                            title: false,
                            btn: ['确定'],
                        });
                        return;
                    }
                    if($("#date").val()=='')
                    {
                        layer.open({
                            content: '请输入手机号',
                            title: false,
                            btn: ['确定'],
                        });
                        return;
                    }
                    if($("#name").val()=='')
                    {
                        layer.open({
                            content: '请输入公司名称',
                            title: false,
                            btn: ['确定'],
                        });
                        return;
                    }
                    if($("#name_ren").val()=='')
                    {
                        layer.open({
                            content: '请输入职位',
                            title: false,
                            btn: ['确定'],
                        });
                        return;
                    }
                    $.ajax({
                        type: 'POST',
                        url: '/FrontActivity/sign_up' ,
                        data: $('form').serialize(),
                        dataType:'json',
                        success:function(data) {
                            console.log(data)
                            if(data.code == 1 ){
                                layer.open({
                                    content: data.msg,
                                    title: false,
                                    btn: ['确定'],
                                    yes:function(){
                                        if(!is_wechat()){
                                            native_listen('back');
                                        }else{
                                            history.go(-1);
                                        }
                                    }
                                });
                            }else if(data.code == 3){
                                layer.open({
                                    content: data.msg,
                                    title: false,
                                    btn: ['确定'],
                                    yes:function(){
                                        if(!is_wechat()){
                                            var dataUrl = '/FrontActivity/activity_order_detail/order_id/'+data.order_id;
                                            var _json = JSON.stringify({
                                                event: "to_jump",
                                                params: {"url":dataUrl}
                                            });
                                            if(is_ios()){
                                                window.webkit.messageHandlers.webviewEvent.postMessage(_json);
                                            }else{
                                                window.ResultAndroid.webviewEvent(_json);
                                            }
                                        }else{
                                            location.href = '/FrontActivity/activity_order_detail/activity_id/'+activity_id;
//                                            history.go(-1);
                                        }
                                    }
                                });
                            }else{
                                layer.open({
                                    content: data.msg,
                                    title: false,
                                    btn: ['确定'],
                                    yes:function(){
                                        if(!is_wechat()){
                                            native_listen('back');
                                        }else{
                                            history.go(-1);
                                        }
                                    }
                                });
                            }
                        }
                    })

                });
            });
        </script>
{/literal}
{/block}
